package xyz.zdsoft.scoring_module.service.Impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Service;
import xyz.zdsoft.common.entity.WorkSubmitInfo;
import xyz.zdsoft.common.service.impl.WorkSubmitInfoServiceImpl;
import xyz.zdsoft.common.utils.Result;
import xyz.zdsoft.scoring_module.bo.ScoresBo;
import xyz.zdsoft.scoring_module.mapper.AdminScoreMapper;
import xyz.zdsoft.scoring_module.service.AdminScoreService;
import xyz.zdsoft.scoring_module.vo.AdminHomeworkVo;
import xyz.zdsoft.scoring_module.vo.AdminPersonScoreVo;
import xyz.zdsoft.scoring_module.vo.AdminTeamScoreVo;
import xyz.zdsoft.scoring_module.vo.TrainTeacherAndTeamMemberVo;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 管理员-综合打分记录业务逻辑处理接口实现类
 * @author 以风
 */
@Service
public class AdminScoreServiceImpl implements AdminScoreService {
    @Resource
    private AdminScoreMapper adminScoreMapper;

    @Resource
    private WorkSubmitInfoServiceImpl workSubmitInfoService;

    /**
     * 获取个人评分（分页、查询、重置）
     * @param page 分页参数
     * @param scoresBo 评分入参
     * @return 个人评分分页信息列表
     */
    @Override
    public IPage<AdminPersonScoreVo> getPersonScorePage(IPage<ScoresBo> page, ScoresBo scoresBo) {
        IPage<AdminPersonScoreVo> personScoreVoIPage = adminScoreMapper.getPersonScorePage(page,scoresBo);
        return personScoreVoIPage;
    }

    /**
     * 获取实训老师
     *
     * @param courseId 课程id
     * @return 实训老师
     */
    @Override
    public String getTrainTeacher(Integer courseId) {
        String trainTeacher =  adminScoreMapper.getTrainTeacher(courseId);
        return trainTeacher;
    }

    /**
     * 获取学生作业信息
     *
     * @param page      分页信息
     * @param courseId  课程id
     * @param studentId 学生id
     * @return 学生作业信息
     */
    @Override
    public IPage<AdminHomeworkVo> getStudentHomeWork(IPage<AdminHomeworkVo> page, Integer courseId, Integer studentId) {
        IPage<AdminHomeworkVo> homeworkVoIPage = adminScoreMapper.getStudentHomeWork(page,courseId,studentId);
        return homeworkVoIPage;
    }

    /**
     * 获取小组评分（分页、查询、重置）
     * @param page 分页参数
     * @param scoresBo 评分入参
     * @return 小组评分分页信息列表
     */
    @Override
    public IPage<AdminTeamScoreVo> getTeamScorePage(IPage<ScoresBo> page, ScoresBo scoresBo) {
        IPage<AdminTeamScoreVo> teamScoreVoIPage = adminScoreMapper.getTeamScorePage(page,scoresBo);
        return teamScoreVoIPage;
    }

    /**
     * 获取实训老师和小组成员
     *
     * @param courseId 课程id
     * @param teamId   小组id
     * @return 实训老师和小组成员
     */
    @Override
    public TrainTeacherAndTeamMemberVo getTrainTeachersAndTeamMembers(Integer courseId, Integer teamId) {
        TrainTeacherAndTeamMemberVo trainTeacherAndTeamMemberVo = adminScoreMapper.getTrainTeachersAndTeamMembers(courseId,teamId);
        return trainTeacherAndTeamMemberVo;
    }

    /**
     * 获取小组作业信息
     *
     * @param page     分页参数
     * @param courseId 课程id
     * @param teamId   小组id
     * @return 小组作业信息
     */
    @Override
    public IPage<AdminHomeworkVo> getTeamHomeWork(IPage<AdminHomeworkVo> page, Integer courseId, Integer teamId) {
        IPage<AdminHomeworkVo> homeworkVoIPage = adminScoreMapper.getTeamHomeWork(page,courseId,teamId);
        return homeworkVoIPage;
    }

    /**
     * 查看作业详情
     * @param homeworkDetailsId 作业详情id
     * @return 作业详情信息
     */
    public WorkSubmitInfo getHomeworkDetails(Long homeworkDetailsId) {
         WorkSubmitInfo workSubmitInfo = workSubmitInfoService.getById(homeworkDetailsId);
         return workSubmitInfo;
    }
}
